home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
vp2_409e.szh
/
SEEN.C
< prev
next >
Wrap
Text File
|
1991-06-27
|
10KB
|
412 lines
/*
$Header: seen.c 3.3 87/12/12 00:45:16 Bob Exp $
The Conference Mail System
This module was originally written by Bob Hartman
Sysop of FidoNet node 1:132/101
Spark Software, 427-3 Amherst St, CS 2032, Suite 232, Nashua, NH 03061
The Conference Mail System is a complete Echomail processing package. It
is a superset of the original Echomail utilities created by Jeff Rush, and
also contains ideas gleaned from the ARCmail, Renum, oMMM, MGM, and Opus
programs that were created by various software authors.
This program source code is being released with the following provisions:
1. You are free to make changes to this source code for use on your own
machine, however, altered source files may not be distributed without the
consent of Spark Software.
2. You may distribute "patches" or "diff" files for any changes that you
have made, provided that the "patch" or "diff" files are also sent to Spark
Software for inclusion in future releases of the entire package. A "diff"
file for the source archives may also contain a compiled version, provided
it is clearly marked as not being created from the original source code.
No other executable versions may be distributed without the consent of
Spark Software.
3. You are free to include portions of this source code in any program you
develop, providing: a) Credit is given to Spark Software for any code that
may is used, and b) The resulting program is free to anyone wanting to use
it, including commercial and government users.
4. There is NO technical support available for dealing with this source
code, or the accompanying executable files. This source code is provided
as is, with no warranty expressed or implied (I hate legalease). In other
words, if you don't know what to do with it, don't use it, and if you are
brave enough to use it, you're on your own.
Spark Software may be contacted by modem at (603) 888-8179 (node 1:132/101)
on the public FidoNet network, or at the address given above.
To use this code you will need Microsoft C version 4.0, and also Microsoft
Macro Assembler version 4.0.
*/
/*
$Log: seen.c $
* Revision 3.3 87/12/12 00:45:16 Bob
* Source code release
*
*/
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include "fastecho.h"
#define DEBUG 0
extern SEACONFIG config;
extern AREAS_PTR areas[];
extern char board_name[], sysop_name[];
extern int tot_areas;
extern char bbsfile[];
extern char *arc_cmd[];
extern int nread;
extern int arc_args;
extern int last_msg;
extern int high_one;
extern int convert;
extern char seen_byline[];
extern char originline[];
extern char tearline[];
extern int max_msgs;
extern int ctrla;
extern int *msg_nums;
extern char *holder1;
extern int mail_low;
extern int mail_high;
extern char *seen_by;
extern char *origin;
extern char *tear;
extern char *holder;
extern int tearl;
extern int originl;
extern int seen_byl;
extern int msgl;
extern int seen_nets[];
extern int seen_nodes[];
extern int not_seen[];
extern int tot_seen;
extern char arealine[];
extern int areal;
extern MSG_PTR h;
extern int msgs_done;
extern int priv_net;
void next_str (char * *p,char *sb_string,int l,int l1)
{
char *p1;
#if DEBUG
printf ("Attempting to find '%s' in:\n%s\n", sb_string, *p);
#endif
p1 = *p;
/* while (1) { */
while (*(*p)) {
#if DEBUG
printf ("calling with '%s', '%c', '%d'\n", *p, *sb_string, l1);
#endif
*p = match_byte (*p, *sb_string, l1);
/* If we are past the end of the message, then get out */
if (*p == NULL)
{
#if DEBUG
printf ("no dice\n");
#endif
*p = (char *) (p1 + l1);
return;
}
#if DEBUG
printf ("Matched here '%s'\n", *p);
#endif
if (strncmp (*p, sb_string, l) != 0)
{
++(*p);
continue;
}
else
{
#if DEBUG
printf("It matched good\n");
#endif
break;
}
}
}
void get_seen_bys (
char *st_string,
int st_stringl,
char *sb_string,
int snets[],
int snodes[],
int *tseen)
{
int j, last_net, l;
char *p;
p = st_string;
last_net = -1;
*tseen = 0;
l = strlen (sb_string);
next_str (&p, sb_string, l, st_stringl);
while (*p)
{
/* Make sure that we can still store them */
if (*tseen >= 450)
break;
/* Get to a digit */
while (*p)
{
/* If it is a digit, we are all set */
if (isdigit(*p))
break;
/* If it is a hard return, then we have to get to the next SB */
else if (*p == '\r')
{
next_str (&p, sb_string, l, st_stringl - (int) (p - st_string));
}
else
++p;
}
if (*p == '\0')
break;
/* Now get the net out of net/node, or just the node */
j = atoi (p);
/* Now get rid of that number */
while (isdigit (*p))
++p;
/* Is it a net/node pair? */
if (*p == '/')
{
++p;
last_net = snets[*tseen] = j;
snodes[*tseen] = atoi (p);
while (isdigit (*p))
++p;
}
else
{
snets[*tseen] = last_net;
snodes[*tseen] = j;
}
#if DEBUG
printf ("Got seen-by %d/%d\n", snets[*tseen], snodes[*tseen]);
#endif
/* This logic assumes that seen-bys are ordered (as they should be) */
if ((snets[*tseen-1] != snets[*tseen]) ||
(snodes[*tseen-1] != snodes[*tseen]))
{
++*tseen;
}
/*
for (k = 0; k < *tseen; k++)
{
if ((snets[k] == snets[*tseen]) &&
(snodes[k] == snodes[*tseen]))
{
break;
}
}
if (k >= *tseen)
++*tseen;
*/
}
}
void create_seen (
char *ptr,
int nets[],
int nodes[],
int num_nodes,
int normal,
char *sb_string)
{
register int cnt1;
int i, lastnet, cnt;
char *curloc;
char *p21;
char next[50];
p21 = ptr;
/* Make the last net be nothing legal */
lastnet = -100;
/* If we are doing the ^A kludge, do it */
if (ctrla)
{
*p21++ = 1;
}
else
{
*p21++ = '\n';
}
strcpy (p21, sb_string);
/* So far the length is zero */
seen_byl = 0;
/* Our count is as many chars as we put in so far */
cnt = strlen (p21) + 1;
/* Current pointer for next one */
curloc = p21+strlen(p21);
/* Now for each node put in the seen-by */
for (i = 0; i < num_nodes; i++)
{
#if DEBUG
printf ("Current is %d/%d\n", nets[i], nodes[i]);
#endif
/* If we are dealing with a private net, be careful */
if (!normal)
{
if (nets[i] == priv_net)
continue;
}
/* If the net or node number is negative, bag it */
if ((nets[i] <= 0) || (nodes[i] < 0))
continue;
/* If it was the same as the last net, don't put in the net number */
if (nets[i] == lastnet)
{
/* itoa (nodes[i], next, 10);
p1 = &next[strlen(next)];
*p1++ = ' ';
*p1 = '\0';
*/
sprintf (next, "%d ", nodes[i]);
#if DEBUG
printf ("next1 = '%s'\n", next);
#endif
}
else
{
/* itoa (nets[i], next, 10);
p1 = &next[strlen(next)];
*p1++ = '/';
itoa (nodes[i], p1, 10);
p1 = &p1[strlen(p1)];
*p1++ = ' ';
*p1 = '\0';
*/
sprintf (next, "%d/%d ", nets[i], nodes[i]);
#if DEBUG
printf ("next = '%s'\n", next);
#endif
/* Set the new lastnet variable */
lastnet = nets[i];
}
#if DEBUG
printf ("currently it is '%s'\n", ptr);
#endif
/* If our current line would be more than 70 chars start a new line */
if (cnt + strlen (next) >= 70)
{
/* Do the ^A kludge properly */
*curloc++ = '\r';
*curloc++ = '\n';
if (ctrla)
{
*curloc++ = 1;
cnt1 = 1;
}
else
{
cnt1 = 0;
}
strcpy (curloc, sb_string);
/* Add in the total count so far */
seen_byl += cnt;
/* The count for this line so far */
cnt = strlen (curloc) + cnt1 + 2;
cnt1 = cnt - cnt1 - 2;
/* Increment the pointer by the right amount */
curloc += cnt1;
/* itoa (nets[i], next, 10);
p1 = &next[strlen(next)];
*p1++ = '/';
itoa (nodes[i], p1, 10);
p1 = &p1[strlen(p1)];
*p1++ = ' ';
*p1 = '\0';
*/
sprintf (next, "%d/%d ", nets[i], nodes[i]);
#if DEBUG
printf ("next2 = '%s'\n", next);
#endif
}
/* Add in the new number */
strcpy (curloc, next);
/* The length of this string so we don't count it again */
cnt1 = strlen (next);
/* Increment the current location pointer */
curloc += cnt1;
/* Increment our line count */
cnt += cnt1;
#if DEBUG
printf ("its '%s'\n", ptr);
#endif
}
strcpy (curloc, "\r\n\r\n");
seen_byl += cnt + 4;
}